<?php
	include 'configure.php';
	
	$func = $_POST['func'];
	
	if($func == "addNum") {
		$id = $_POST['id'];
		$result = mysql_query("select * from components where uid = $id");
		if($row = mysql_fetch_array($result)) {
			$num = $row["num"];
			$num++;
			$query = "update components set num = $num where uid = $id";
			if(mysql_query($query)) echo "$num";
			else echo "0|操作失败";
		}
	}
	else if($func == "minNum") {
		$id = $_POST['id'];
		$result = mysql_query("select * from components where uid = $id");
		if($row = mysql_fetch_array($result)) {
			$num = $row["num"];
			$num--;
			if($num == 0) $query = "delete from components where uid = $id";
			else $query = "update components set num = $num where uid = $id";
			if(mysql_query($query)) echo "$num";
			else echo "0|操作失败";
		}
	}
?>